<?php
namespace backend\controllers;
use Yii;
use common\models\Activity\Activity;
use common\models\project\Project;
use common\models\Activity\ActivitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use zhongkefu\zhongkefu;
use zhongkefu\helpers\Utils;

class TaskplanController extends Controller
{
 	public function actionTaskactivity()
	{
		$activity = Activity::find()->andWhere(['ac_status'=>Activity::ACSTATUS_ACTIVE])->all();
		$time = time();
		foreach($activity as $k=>$vo){
			if($vo->start_time < $time && $time < $vo->end_time){
				Activity::updateAll(['ac_display'=>20],['ac_id'=>$vo->ac_id]);
				$actnew = Activity::findOne(['ac_id'=>$vo->ac_id]);//状态修改后
			}elseif($vo->end_time < $time){
				Activity::updateAll(['ac_display'=>40],['ac_id'=>$vo->ac_id]);
				$actnew = Activity::findOne(['ac_id'=>$vo->ac_id]);//状态修改后
			}else{
				Activity::updateAll(['ac_display'=>0],['ac_id'=>$vo->ac_id]);
				$actold = Activity::findOne(['ac_id'=>$vo->ac_id]);//状态修改后
			}
	    }
	}

	

	public function actionTaskproject()
	{
		$projects = Project::find()->all();
		$time = time();
		foreach($projects as $k=>$vo){
			if($vo->starttime < $time && $time < $vo->endtime){
				Project::updateAll(['status'=>Project::STATUS_ACTIVE],['id'=>$vo->id]);
				$actnew = Project::findOne(['id'=>$vo->id]);//状态修改后
			}elseif($vo->endtime < $time){
				Project::updateAll(['status'=>Project::STATUS_INACTIVE],['id'=>$vo->id]);
				$actnew = Project::findOne(['id'=>$vo->id]);//状态修改后
			}else{
				Project::updateAll(['status'=>Project::STATUS_BEFORE],['id'=>$vo->id]);
				$actold = Project::findOne(['id'=>$vo->id]);//状态修改后
			}
	    }
	}

	//活动开始一周前发邮件
	public function actionSendemailall(){
		$time = time();
	}





	
}